home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 2
/
Amiga Tools 2.iso
/
grafik
/
bildanzeiger
/
seepix
/
source.lha
/
FadeTo.c
< prev
next >
Wrap
Text File
|
1992-11-27
|
6KB
|
176 lines
/**FadeTo.c**************************************************************
* *
* SeePix -- by Hank Schafer *
* *
* SeePix is an IFF Picture Viewer. It works with Lo-Res, *
* Med-Res, Hi-Res, HAM, and EHB formats. I'm working on support *
* for X-Specs, and Anim5 formats. *
* *
* SeePix is based on a program by Olaf Barthel, called *
* 'LoadImage'. As released, LoadImage had a couple of bugs. *
* The Amiga-Key alternatives to menu use didn't all work. That's *
* been fixed. There were two separate print functions in LoadImage *
* which behaved exactly the same. The redundancy was eliminated. *
* LoadImage used the Topaz ROMFONT, and made no allowances for a *
* different system default font (under 2.04). I added a built-in *
* font. I've reworked the code considerably from the original *
* release, to allow for optimizations based on time and space. *
* *
* SeePix features a palette tool which allows "tweaking" of colors *
* prior to printing, allowing you to modify the color printout to *
* more closely resemble the original graphics (Blue is Blue, not *
* Purple). SeePix can be Iconified. SeePix features an ARP *
* interface. SeePix now uses the PathMaster File Selector. *
* *
************************************************************************
* *
* SeePix Copyright © 1992 by Hank Schafer; all rights reserved. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 1, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to: *
* Free Software Foundation, Inc. *
* 675 Massachusetts Ave. *
* Cambridge MA 02139, USA *
* *
**************** Special Function Copyright Notices ********************
* *
****LoadImage Copyright Notice: *
* *
* LoadImage is © Copyright 1988, 1989, 1990 by MXM, all rights *
* reserved, written by Olaf Barthel. No guarantees of any kind are *
* made that this program is 100% reliable. Use this program on *
* your own risk! *
* *
****Iconify Copyright Notice: *
* *
* Copyright 1987 by Leo L. Schwab. *
* Permission is hereby granted for use in any and all programs, *
* both Public Domain and commercial in nature, provided this *
* Copyright notice is left intact. *
* *
****ColorWindow (Palette) Copyright Notice: *
* *
* ColorWindow Routine -- Color Window Routines *
* from Book 1 of the Amiga Programmers' Suite by RJ Mical *
* *
* Copyright (C) 1986, 1987, Robert J. Mical *
* All Rights Reserved. *
* *
****PathMaster Copyright Notice: *
* *
* -------------------------------------------------------------------- *
* Copyright © 1989 Justin V. McCormick. All Rights Reserved. *
* -------------------------------------------------------------------- *
* *
* The PathMaster name is a trademark of Justin V. McCormick. *
* *
* PathMaster File Selector source and documentation written by: *
* *
* Justin V. McCormick. *
* Copyright © 1989 by Justin V. McCormick. *
* All Rights Reserved. *
* *
* -------------------------------------------------------------------- *
************************************************************************
* *
* Hope this is something you can use and enjoy. *
* *
************************************************************************/
/*
* FadeTo():
*
* Fades a palette into a different palette or color.
*/
VOID
FadeTo(struct ViewPort * VPort, UWORD * From, UWORD * To, LONG NumColors, LONG ToCol, LONG FromCol)
{
UWORD FromTemp[32];
UWORD ToTemp[32];
WORD i, j, R1, G1, B1, R2, G2, B2;
/* A bit too large? */
if (NumColors > 32)
NumColors = 32;
/* Do we have a source palette? */
if (From)
CopyMem(&From[0], &FromTemp[0], sizeof(UWORD) * 32);
else
memset(&FromTemp[0], FromCol, sizeof(UWORD) * 32);
/* Do we have a destination palette? */
if (To)
CopyMem(&To[0], &ToTemp[0], sizeof(UWORD) * 32);
else
memset(&ToTemp[0], ToCol, sizeof(UWORD) * 32);
/* Let's get into action. */
for (j = 0; j < 16; j++) {
for (i = 0; i < NumColors; i++) {
/* Split the source color. */
R1 = (FromTemp[i] >> 8) & 0xF;
G1 = (FromTemp[i] >> 4) & 0xF;
B1 = (FromTemp[i]) & 0xF;
/* Split the destination color. */
R2 = (ToTemp[i] >> 8) & 0xF;
G2 = (ToTemp[i] >> 4) & 0xF;
B2 = (ToTemp[i]) & 0xF;
/* Adjust the colors. */
if (R1 > R2)
R1--;
if (G1 > G2)
G1--;
if (B1 > B2)
B1--;
/* Adjust the colors. */
if (R1 < R2)
R1++;
if (G1 < G2)
G1++;
if (B1 < B2)
B1++;
/* Put it together again. */
FromTemp[i] = (R1 << 8) | (G1 << 4) | B1;
}
/* Wait a bit. */
Delay(2);
/* Load the new map. */
LoadRGB4(VPort, FromTemp, NumColors);
}
}